const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const devConfig = require('./webpack.dev.js');
const util = require('util');

// 等同于 webpack.dev.js -> devServer
new WebpackDevServer(webpack(devConfig), {
    publicPath: devConfig.output.publicPath,
    hot: true,
    stats: {
        colors: true
    },
    historyApiFallback: true,
    contentBase: '/build/',
    devtool: 'eval',
    inline: true,
    host: 'localhost',
    port: 8080,
    proxy: {
        '/api': {
            target: 'http://www.kuaidiapi.cn/',
            pathRewrite: {
                '^/api': ''
            },
            changeOrigin: true,
            secure: false
        }
    }
}).listen(8080, 'localhost', (err, result) => {
    if (err) console.log(err);
    console.log('正在编译中...')
})